import Vue from 'vue'
import Router from 'vue-router'
import Hello from '@/components/Hello'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'Hello',
      component: Hello
    },
    {
      path: '/course/list',
      name: 'courseList',
      component: (resolve) => {
        require.ensure(['../views/PageCourseList.vue'], () => {
          resolve(require('../views/PageCourseList.vue')) // eslint-disable-line global-require
        })
      }
    },
    {
      path: '/course/detail/:id',
      name: 'courseDetail',
      component: (resolve) => {
        require.ensure(['../views/PageCourseDetail.vue'], () => {
          resolve(require('../views/PageCourseDetail.vue')) // eslint-disable-line global-require
        })
      }
    },
    {
      path: '/pay/method/',
      name: 'pay',
      component: (resolve) => {
        require.ensure(['../views/PagePayMethod.vue'], () => {
          resolve(require('../views/PagePayMethod.vue')) // eslint-disable-line global-require
        })
      }
    },
    {
      path: '/user',
      name: 'user',
      component: (resolve) => {
        require.ensure(['../views/PageUserCenter.vue'], () => {
          resolve(require('../views/PageUserCenter.vue')) // eslint-disable-line global-require
        })
      },
      children: [
        {
          path: 'car',
          name: 'shoppingCar',
          component: (resolve) => {
            require.ensure(['../views/PageCarList.vue'], () => {
              resolve(require('../views/PageCarList.vue')) // eslint-disable-line global-require
            })
          }
        },
        {
          path: 'orderList',
          name: 'orderList',
          component: (resolve) => {
            require.ensure(['../views/PageOrderList.vue'], () => {
              resolve(require('../views/PageOrderList.vue')) // eslint-disable-line global-require
            })
          }
        }
      ]
    },
    {
      path: '/video/:cid/:sid/:vid',
      name: 'videoDetail',
      component: (resolve) => {
        require.ensure(['../views/PageVideoDetail.vue'], () => {
          resolve(require('../views/PageVideoDetail.vue')) // eslint-disable-line global-require
        })
      }
    },
    {
      path: '/order/:tradeNo',
      name: 'orderDetail',
      component: (resolve) => {
        require.ensure(['../views/PageOrderDetail.vue'], () => {
          resolve(require('../views/PageOrderDetail.vue')) // eslint-disable-line global-require
        })
      }
    }
  ]
})
